package com.xiaoKe.zhonghzu.global.okhttp;

import com.xiaoKe.zhonghzu.global.tool.LoggerTool;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * @ProjectName : xiaoke-pad-zhongzhu
 * @Author : Shijingna
 * @Time : 2024/7/15 14:12
 * @Description : 请求响应中转站
 */
public class ApiCallback implements Callback {
    ApiCallbackOnResponse apiCallbackOnResponse;

    public ApiCallback(ApiCallbackOnResponse apiCallbackOnResponse) {
        this.apiCallbackOnResponse = apiCallbackOnResponse;
    }

    @Override
    public void onResponse(Call call, Response response) {
        if (response.code() == 200) {
            apiCallbackOnResponse.onResponse(response.body());
        }
    }

    @Override
    public void onFailure(Call call, Throwable t) {
        LoggerTool.d("接口："+t.getMessage());
    }

}
